<template>
  <view style="padding-bottom: 10rpx;">
    <!-- 收支碳能量数量-->
    <uni-card :is-shadow="false">
      <view class="flex_between" style="margin-bottom: 0;">
        <view style="margin-bottom: 0;">
          <span style="margin-right: 15rpx;">提现金额：</span>
          <span class="common-money themeColor">{{ dataDetails.accountMoney }}</span>&nbsp;元
        </view>
        <view v-if="dataDetails.status == 2" style="margin-bottom: 0;" @click="handleRevoke(dataDetails)">
          <uni-icons type="undo" size="18" color="#f78989"></uni-icons>
          <text class="card-actions-item-text errorColor">撤销</text>
        </view>
      </view>
    </uni-card>

    <!-- 基本信息-->
    <uni-card title="基本信息" :is-shadow="false">
      <view>提现编号：<span>{{ dataDetails.number }}</span></view>
      <view>提现碳能量：<span>{{ dataDetails.integral }}g</span></view>
      <view>可兑换现金：<span>{{ dataDetails.exchangeMoney }}元</span></view>
      <view>代扣个税：<span>{{ dataDetails.taxation }}元</span></view>
      <view>提现服务费：<span>{{ dataDetails.serviceCharge }}元</span></view>
      <view>申请时间：<span>{{ dataDetails.createTime }}</span></view>
      <view v-if="dataDetails.status == 0">审核时间：<span>{{ dataDetails.completeTime }}</span></view>
      <view v-else-if="dataDetails.status == 3">撤销时间：<span>{{ dataDetails.completeTime }}</span></view>
      <view v-else>完成时间：<span>{{ dataDetails.completeTime }}</span></view>
      <view>提现状态：
        <template v-for="(item, index) in dicts.ec_staff_integral_withdrawal_status">
          <template v-if="dataDetails.status == item.value">
            <uni-tag :text="item.text" size="small" :type="item.type"/>
          </template>
        </template>
      </view>
      <view v-if="dataDetails.status == 0">失败原因：<span>{{ dataDetails.remark }}</span></view>
      <view v-else>审核备注：<span>{{ dataDetails.remark }}</span></view>
    </uni-card>

    <!-- 银行卡信息-->
    <uni-card title="银行卡信息" :is-shadow="false">
      <view>银行开户行名称：<span>{{ dataDetails.bankName }}</span></view>
      <view>银行卡卡号：<span>{{ dataDetails.bankNumber }}g</span></view>
      <view>开户人名称：<span>{{ dataDetails.bankPersonName }}</span></view>
      <view>开户支行名称：<span>{{ dataDetails.bankBranchName }}</span></view>
      <view>银行开户城市：<span>{{ dataDetails.bankCity }}</span></view>
    </uni-card>
  </view>
</template>

<script>
import {getStaffIntegralWithdrawal, revokeStaffIntegralWithdrawal} from "@/api/ec/person/user/staffIntegralWithdrawal";
import {getDictsByNameForUni} from "../../../../../utils/dicts";

export default {
  data() {
    return {
      // 数据字典
      dicts: {
        // 提现状态
        ec_staff_integral_withdrawal_status: [],
      },
      // 详情数据
      dataDetails: {},
    }
  },
  onLoad(option) {
    // 加载字典数据
    this.getDicts()
    // 获取参数
    this.dataDetails = JSON.parse(option.dataDetails)
  },
  created() {
    this.getStaffIntegralWithdrawal();
  },
  methods: {
    // ===============================================================================================================
    // ==== 加载数据字典
    // ===============================================================================================================
    /**加载数据字典*/
    getDicts() {
      // 提现状态
      this.dicts.ec_staff_integral_withdrawal_status = getDictsByNameForUni("ec_staff_integral_withdrawal_status");
    },
    /** 获取订单详情 */
    getStaffIntegralWithdrawal() {
      this.$modal.loading();
      getStaffIntegralWithdrawal(this.dataDetails.id).then(response => {
        uni.hideLoading();
        this.dataDetails = response.data;
      }).catch(() => {
        uni.hideLoading();
      });
    },
    /** 撤销 */
    handleRevoke(dataDetails) {
      let that = this
      uni.showModal({
        title: '系统提示',
        content: '是否撤销提现申请？撤销后碳能量将退回您账户。',
        confirmColor: '#00a660',
        success: function (res) {
          if (res.confirm) {
            let data = {id: dataDetails.id};
            this.$modal.loading();
            revokeStaffIntegralWithdrawal(data).then(() => {
              uni.hideLoading();
              uni.$emit('refreshWithdrawalRecordIndex');
              // 延迟500毫秒显示loading效果
              setTimeout(() => {
                // 执行查询的方法
                that.getStaffIntegralWithdrawal(dataDetails.id);
                that.$modal.msgSuccess("撤销提现成功");
              }, 500)
            }).catch(() => {
              uni.hideLoading();
            });
          }
        }
      })
    },
  }
}
</script>

<style lang="scss" scoped>
::v-deep .uni-collapse-item__title-box {
  background: #fff;
  padding: 0;
}

::v-deep .uniui-bottom {
  color: #ccc !important;
}

page {
  background: $uni-bg-color;
}

view {
  margin-bottom: 16rpx;
}

.common-money {
  font-size: 40rpx;
  font-family: PingFangSC-Semibold, PingFang SC;
  font-weight: 600;
  line-height: 40rpx;
  margin-right: 15rpx;
}

</style>
